<div class="layuimini-main">
    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">节点别名</label>
            <div class="layui-input-block">
                <input type="text" name="nodeBName" lay-verify="required" lay-reqtext="节点别名不能为空" placeholder="请输入节点别名" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">节点地址</label>
            <div class="layui-input-block">
                <input type="text" name="nodeHost" lay-verify="required" lay-reqtext="节点地址不能为空" placeholder="请输入节点地址" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">节点端口</label>
            <div class="layui-input-block">
            	<input type="number" name="nodePort" placeholder="请输入节点端口" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">节点用户</label>
            <div class="layui-input-block">
            	<input type="text" name="nodeUser" lay-verify="required" lay-reqtext="节点用户不能为空" placeholder="请输入节点用户" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">节点密码</label>
            <div class="layui-input-block">
            	<input type="password" name="nodePasw" lay-verify="required" lay-reqtext="节点密码不能为空" placeholder="请输入节点密码" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">保存</button>
                <button class="layui-btn layui-btn-danger" id="closeTPage">取消</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;
        //监听提交
        form.on('submit(saveBtn)', function (data) {
        	axios({
        		method:"post",
        		url:"node/add",
        		data:data.field
        	}).then(function(response){
        		var data = response.data
        		if(data.success){
        			 layer.close(parentIndex);
        		}else{
        			layer.msg(data.errorMsg, {icon: 2});
        		}
        	});
            return false;
        });
        $("#closeTPage").click(function () {
        	layer.close(parentIndex);
        });
    });
</script>